package net.ithe;

public class Demo {
    private static ThreadLocal<String> local = new ThreadLocal<>();
    public static void main(String[] args) {
        local.set("Machine");

        //创建一个线程
        new Thread(new Runnable(){
            @Override
            public void run() {
                local.set("Thread");
                System.out.println(Thread.currentThread().getName() + ":" + local.get());
            }
        }).start();

        System.out.println(Thread.currentThread().getName() + ":" + local.get());
        local.remove();
        System.out.println(Thread.currentThread().getName() + ":" + local.get());
    }
}
